const http = require("http");
const url = require("url");
const route = require("./module/route")

http.createServer(function(req,res){
    //创建静态web服务
    route.static(req,res,"static");

    //路由
    let pathName = url.parse(req.url).pathname;

    if(pathName == "/login"){
        res.writeHead(200, {'Content-Type': 'text/html;charset="utf-8"'}); 
        res.end("执行登录"); 
    }else if (pathName == "/register"){
        res.writeHead(200, {'Content-Type': 'text/html;charset="utf-8"'}); 
        res.end("执行注册");
    }else if (pathName == "/admin"){
        res.writeHead(200, {'Content-Type': 'text/html;charset="utf-8"'}); 
        res.end("处理后台逻辑");   
    }else{
        res.writeHead(404, {'Content-Type': 'text/html;charset="utf-8"'}); 
        res.end("页面不存在！");   
    }

}).listen(3000);

console.log('Server running at http://127.0.0.1:3000/');